<?php !defined("IN_SYSTEM") && exit("ACCESS DENY");?>
<?php include template('header');include template('top');?>
<div id="uc">
{template uc/left}
	<div id="uc_main">
		<div class="uc_tab">
			<ul>
			<li><span><a<?php if(!isset($_GET['gid'])): ?> class="on"<?php endif;?> href="<?=url('home.php?f=friend')?>"><?php echo $lang['all_friend'];?></a></span></li>
			<?php foreach($group as $k=>$v):?>
			<li><span><a<?php if(isset($_GET['gid']) && $_GET['gid']==$k): ?> class="on"<?php endif;?> href="<?=url('home.php?f=friend&gid='.$k)?>"><?php echo $v;?></a></span></li>
			<?php endforeach;?>
			</ul>
		</div>
		<div id="uc_contain">
		<?php if($action == 'list' || !$action):?>
			<form action="{echo url('home.php?f=friend')}" method="POST" class="uc_search">
		{$lang['search_friend']}: <input type="text" name="search_field" class="txt" size="32" onclick="if(this.value=='{$lang['search_friend_tip']}'){ this.value='';}" onblur="if(this.value==''){ this.value='{$lang['search_friend_tip']}';}" id="search_field" value="{if $field}{$field}{else}{$lang['search_friend_tip']}{/if}"/>
			<input type="submit" value="{$lang['search']}"/>
			</form>
		
		
			<table class="uc_table" >
				<tr>
				<th>id</th><th><?php echo $lang['name'];?></th><th><?php echo $lang['sex'];?></th><th><?php echo $lang['family'];?></th><th><?php echo $lang['born'];?></th><th><?php echo $lang['last_meet_time'];?></th><th><?php echo $lang['qq'];?></th><th><?php echo $lang['phone'];?></th>
				<th><?php echo $lang['tel'];?></th><th><?php echo $lang['operation'];?></th>
				</tr>
			<?php foreach($friends as $friend) :?>
			<tr id="tr<?php echo $friend['fid'];?>">
			<td><?php echo $friend['fid'];?></td>
			<td><?php echo $friend['name'];?></td>
			<td><?php echo $sex[$friend['sex']];?></td>
			<td><?php echo $group[$friend['gid']];?></td>
			<td><?php echo gdate('Y-m-d',$friend['born']);?></td>
			<td><?php echo gdate('Y-m-d',$friend['lasttime']);?></td>
			<td><?php echo $friend['qq'];?></td>
			<td><?php echo $friend['phone'];?></td>
			<td><?php echo $friend['tel'];?></td>
			<td><a href="<?php echo url("home.php?f=friend&a=edit&ajax=1&id=".$friend['fid']);?>" target="_blank" onclick="return chanfefriend(this.href);" >[<?php echo $lang['change'];?>]</a> <a href="<?php echo url("home.php?f=friend&a=del&ajax=1&id=".$friend['fid']);?>" onclick="return deletefrind(this.href,'tr<?php echo $friend['fid'];?>');" target="_blank">[<?php echo $lang['delete'];?>]</a> <a href="<?php echo url("home.php?f=friend&a=detail&id=".$friend['fid']);?>" target="_blank">[<?php echo $lang['detail'];?>]</a></td>
			</tr>
			<?php endforeach;?>
			</table>
			<?php echo $pager;?>
		
		<?php endif;?>
		<?php if($action == 'add' || $action == 'edit'):?>
			<form name="friend_add" method="post" action="<?=url('home.php?f=friend&a=save')?>" enctype="multipart/form-data">
			<input type="hidden" name="id" value="<?=$data['fid']?>" />
			<table cellspacing="0" class="uc_fa_table">
		<tr>
			<td colspan="2"><img src="<?php if($data['avatar']):?><?php echo $data['avatar'];?><?php else:?>static/images/avatar.jpg<?php endif;?>" style="width:60px;height:70px;float:left;margin-right:5px;"></img>
			<a href="javascript:;"><?php echo $lang['upload_new_avatar']?>:</a><br/>
			<input type="file" name="avatar" id="avatar" size="17"/><br/>
			<span class="uc_tips"><?php echo $lang['avatar_size_desc']?></span>
			</td>
			<td colspan="2">
			<table>
			<tr>
			<td class="td1" ><?php echo $lang['name'];?>：</td>
			<td><input type="text" name="name" class="input" size="22" value="<?php echo $data['name']?>" /></td>
			</tr><tr>
			<td class="td1" style="border:0 none;"><?php echo $lang['sex'];?>：</td>
			<td style="border:0 none;"><input type="radio" name="sex" <?php if($data['sex'] == 0):?>checked<?php endif;?> value="0" /><?php echo $sex['0'];?>  <input type="radio" name="sex" value="1" <?php if($data['sex'] == 1):?>checked<?php endif;?> /><?php echo $sex['1'];?> </td>
		
			</tr>
			</table>
			</td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['marry_status'];?>：</td>
			<td><select name="marry"><option value="0" <?php if($data['marry']==0):?>selected="selected"<?php endif;?> ><?php echo $lang['unmarried'];?></option><option value="1" <?php if($data['marry']==1):?>selected="selected"<?php endif;?> ><?php echo $lang['married'];?></option><option value="2" <?php if($data['marry']==2):?>selected="selected"<?php endif;?> ><?php echo $lang['divorced'];?></option></select></td>
			<td class="td2"><?php echo $lang['family'];?>：</td>
			<td><select name="gid"><?php foreach($group as $k=>$v):?><option value="<?php echo $k;?>" <?php if($data['gid']==$k):?>selected="selected"<?php endif;?> ><?php echo $v;?></option><?php endforeach;?></select></td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['blood_type'];?>：</td>
			<td><select name="blood"><?php foreach($blood as $k=>$v):?><option value="<?php echo $k;?>" <?php if($data['blood']==$k):?>selected="selected"<?php endif;?> ><?php echo $v;?></option><?php endforeach;?></select></td>
			<td class="td2"><?php echo $lang['edu'];?>：</td>
			<td><select name="edu"><?php foreach($edu as $k=>$v):?><option value="<?php echo $k;?>" <?php if($data['edu']==$k):?>selected="selected"<?php endif;?> ><?php echo $v;?></option><?php endforeach;?></select></td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['body_height'];?>：</td>
			<td><select name="height"><?php foreach($height as $k=>$v):?><option value="<?php echo $k;?>" <?php if($data['height']==$k):?>selected="selected"<?php endif;?> >{if $v<145}{echo $v.' '.$lang['undercm']}{elseif $v>195}{echo $v.' '.$lang['overcm']}{else}{echo $v.' '.$lang['centimeter']}{/if}</option><?php endforeach;?></select></td>
			<td class="td2"><?php echo $lang['body_weight'];?>：</td>
			<td><select name="weight"><?php foreach($weight as $k=>$v):?><option value="<?php echo $k;?>" <?php if($data['weight']==$k):?>selected="selected"<?php endif;?> >{if $v<40}{echo $v.' '.$lang['undercm']}{elseif $v>120}{echo $v.' '.$lang['overcm']}{else}{echo $v.' '.$lang['kilogram']}{/if}</option><?php endforeach;?></select></td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['monthly_income']?>：</td>
			<td><select name="wage"><?php foreach($wage as $k=>$v):?><option value="<?php echo $k;?>" <?php if($data['wage']==$k):?>selected="selected"<?php endif;?>><?php echo $v;?></option><?php endforeach;?></select></td>
			<td class="td2"><?php echo $lang['born'];?>：</td>
			<td colspan="3">
			<input name="birthday" id="birthday" class="input" size="22" value="{$data['born']}"  onclick="showcalendar(event);" />
			</td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['meet_time'];?>：</td>
			<td>
			<input name="addtime" id="addtime" class="input" size="22" value="{$data['addtime']}"  onclick="showcalendar(event);" />
			</td>
			<td class="td1"><?php echo $lang['last_meet_time'];?>：</td>
			<td >
			<input name="lasttime" id="lasttime" class="input" size="22" value="{$data['lasttime']}"  onclick="showcalendar(event);" />
			</td>
		
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['qq'];?>：</td>
			<td ><input type="text" name="qq" class="input" size="22" value="<?=$data['qq']?>" /></td>
			<td class="td2"><?php echo $lang['mail'];?>：</td>
			<td ><input type="text" name="mail" class="input" size="22" value="<?=$data['mail']?>" /></td>
		
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['phone'];?>：</td>
			<td ><input type="text" name="phone" class="input" size="22" value="<?=$data['phone']?>"/></td>
			<td class="td2"><?php echo $lang['tel'];?>：</td>
			<td ><input type="text" name="tel" class="input" size="22" value="<?=$data['tel']?>" /></td>
		
		</tr>
		
		<tr>
			<td class="td1"><?php echo $lang['addr'];?>：</td>
			<td colspan="3">
			<select name="prov1" id="prov1" onchange="getcity(this,'city1')"><option value="0"><?php echo $lang['province'];?></option><?php foreach ($prov as $k=>$v):?><option value="<?php echo $k;?>" <?php if($k == $data['prov1']):?>selected="selected"<?php endif;?>><?php echo $v;?></option><?php endforeach;?></select>
			<select name="city1" id="city1" onchange=""><option value="0"><?php echo $lang['city'];?></option><?php foreach ($city[$data['prov1']] as $k=>$v):?><option value="<?php echo $k;?>" <?php if($k == $data['city1']):?>selected="selected"<?php endif;?>><?php echo $v;?></option><?php endforeach;?></select>
			<input type="text" name="addr1" class="input" size="31" value="<?=$data['addr1']?>" /></td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['addr1'];?>：</td>
			<td colspan="3">
			<select name="prov2" id="prov2" onchange="getcity(this,'city2')"><option value="0"><?php echo $lang['province'];?></option><?php foreach ($prov as $k=>$v):?><option value="<?php echo $k;?>" <?php if($k == $data['prov2']):?>selected="selected"<?php endif;?>><?php echo $v;?></option><?php endforeach;?></select>
			<select name="city2" id="city2" onchange=""><option value="0"><?php echo $lang['city'];?></option><?php foreach ($city[$data['prov2']] as $k=>$v):?><option value="<?php echo $k;?>" <?php if($k == $data['city2']):?>selected="selected"<?php endif;?>><?php echo $v;?></option><?php endforeach;?></select>
			<input type="text" name="addr2" class="input" size="31" value="<?=$data['addr2']?>" /></td>
		</tr>
		
		
		<tr>
			<td class="td1"><?php echo $lang['hobby'];?>：</td>
			<td colspan="3"><input type="text" name="hobby" class="input" size="52" value="<?=$data['hobby']?>" /></td>
		</tr>
		<tr>
			<td class="td1"><?php echo $lang['extra'];?>：</td>
			<td colspan="3"><textarea  name="extra" cols="51" ><?php echo $data['extra'];?></textarea></td>
		</tr>
		<tr class="bg2"><td></td><td colspan="3"><input type="submit" class="button" value="<?php echo $lang['submit'];?>" /> </td></tr>
	</table>
	</form>
		
		<?php endif;?>
		<?php if($action == 'del'):?>
		<?php endif;?>
		
		
		
		</div>
	</div>

	<div id="uc_right"></div>
</div>
<script type="text/javascript">
function chanfefriend(u){
	var edit = art.dialog({
	    title: '<?php echo $lang['change_friend']?>',
	    lock: true,
	    fixed: true, //C=G.DW
	    width:560,
	    height:400,
	    padding:'0 0 0 15px',
	    cssname:'uc_editfrind',
	    content: '<iframe src="'+u+'" frameborder="0" style="width:560px;height:400px;" />'
		});
	
	return false;
}
function deletefrind(u,id){
	if(confirm('<?php echo $lang["confirm_delete"];?>')){
		$.getJSON(u+'&tm='+Math.random(),'',function(data){
			if(data.status==true){
				$('#'+id).hide();
			}else{
				art.dialog({fixed: true,time: 2,content: data.msg});
			}
			});
	}
	return false;
	
}
</script>

<?php include template('footer')?>